home *** CD-ROM | disk | FTP | other *** search
AMOS Source Code | 1980-05-17 | 1.7 KB | 37 lines |
- '**************THE WORLD IS EVER-CHANGING-By Mark Wickson*********************
- Rem Variables-They're the key to good programming-And alot of the examples on
- Rem this disk use them.
- Rem For a better definition of variables look at the on-disk document files.
- Rem A variable is something that changes(It VARIES-Hence variable),in
- Rem programming,alot of coordinates can be variables,and you can work out
- Rem complicated problems with them.If I had a coordinate,for example,it
- Rem start at 5(So lets imagine it was a Bobs horizontal coordinate in a
- Rem main loop of a game):
- Rem Bob 1,5,100,1
- Rem But now I want to make the Bobs horizontal value change-I could write
- Rem Bob 1,10,100,1
- Rem but if I want to make the horizontal value change again,I'd have
- Rem to write:
- Rem Bob 1,15,100,1
- Rem As you can see,if I don't want to make its position change drastically
- Rem in one step,I have to write alot of lines-Unless I use a variable.
- Rem A variable must be given a name-In this case,we're manipulating the
- Rem X axis of a Bob,so why not call it "X"(You could call it almost anything)
- Rem-First we have to write its starting point,in this case we want it to
- Rem start at 5:
- Rem X=5
- Rem Then wewrite inside our loop:
- Rem X=X+5
- Rem So every loop,"X" is increased by 5-Then we would substitute the
- Rem horizontal coordinate for our variable:
- Rem Bob 1,X,100,1
- Rem So now the Bob is displayed at new positions easily.
- Rem Anything that uses numbers(Or text) can be manipulated by variables.
- Rem in this example,we print the latest value of the variable "X"-Each loop,
- Rem we increase its value by one.
- Rem YOU'LL HAVE TO BREAK OUT OF THIS WHEN YOU GET BORED!
- X=0
- Do
- X=X+1
- Print At(0,0);X
- Loop